<?php

/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Sitepagealbum
 * @copyright  Copyright 2010-2011 BigStep Technologies Pvt. Ltd.
 * @license    http://www.socialengineaddons.com/license/
 * @version    $Id: Core.php 2011-05-05 9:40:21Z SocialEngineAddOns $
 * @author     SocialEngineAddOns
 */
class Sitepagealbum_Api_Core extends Core_Api_Abstract {
	
	/**
	 * Delete the sitepage album and photos
	 * 
	 * @param int $album_id
	 */
	public function deleteContent($album_id) {
		
		$album = Engine_Api::_ ()->getItem ( 'sitepage_album', $album_id );
		
		if (empty ( $album )) {
			return;
		}
		
		//DELETE IMAGE
		$tablePhoto = Engine_Api::_ ()->getItemTable ( 'sitepage_photo' );
		$select = $tablePhoto->select ()->where ( 'album_id = ?', $album_id );
		$rows = $tablePhoto->fetchAll ( $select );
		if (! empty ( $rows )) {
			foreach ( $rows as $photo ) {
				$photo->delete ();
			}
		}
		
		//DELETE ALBUM
		$album->delete ();
	}
}

?>